/**
 *
 * @param {*} api
 * from tecent
 */
const wxPify = api => params =>
  new Promise((resolve, reject) => {
    if (!api) {
      wx.showModal({
        title: '提示',
        content: '当前微信版本过低，无法使用该功能，请升级到最新微信版本后重试',
        complete: () => reject(),
        confirmColor: '#006eff',
        showCancel: false
      });
    } else {
      api.call(wx, { ...params, success: resolve, fail: reject });
    }
  });

export { wxPify };
